#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	string s1,s2;
	string tem1,tem2;
	getline(cin,s1);
	getline(cin,s2);
	if(s1.length()<=s2.length())
	{
		tem1=s1;
		tem2=s2;
	}
	else
	{
		tem1=s2;
		tem2=s1;
	}
	for(int i=0;i<tem2.length();i++)
	{
		if(tem1[0]==tem2[i])
		{
			for(int j=0;j<tem1.length();j++)
			{
				if(tem1[j]==tem2[i+j])
				{
					if(j==tem1.length()-1)
					{
						cout<<tem1<<" is substring of "<<tem2;
						return 0;
					}
				}
				else break;
			}
		}
		
	}
	cout<<"No substring";
	return 0;
}

